import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
import { SGuildInfo } from "../../../../Message/Game/SGuildInfo";
import { GuildConfig } from "../../resource/GuildConfig";
import { GuildUtil } from "./info/GuildUtil";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
import { GLabel } from "../../../../com/mui/controls/GLabel";
//class GuildDetailWindow
    
    export  class GuildDetailWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this._nameArray = Language.getArrayByStr(57016);
            this._fieldArray = [];
            this.init();
            return;
        }

        public init(): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=null;
            this.setSize(365, 210);
            this.titleHeight = 32;
            loc1 = 16777113;
            ObjCreate.createBg(17, 44, 330, 154, this);
            this.title = Language.getString(57017);
            loc2 = 0;
            while (loc2 < this._nameArray.length) 
            {
                loc3 = new GTextFiled();
                loc3.x = 20;
                loc3.y = loc2 * 25 + 45;
                loc3.htmlText = HTMLUtil.addColor(this._nameArray[loc2], "#ffff99");
                loc3.autoSize = flash.text.TextFieldAutoSize.LEFT;
                addChild(loc3);
                this._fieldArray.push(loc3);
                ++loc2;
            }
            this._campText = new GTextFiled();
            this._campText.text = Language.getString(57018);
            this._campText.textColor = loc1;
            this._campText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._campText.x = 175;
            this._campText.y = 45;
            addChild(this._campText);
            this._chairmanText = new GTextFiled();
            this._chairmanText.text = Language.getString(57019);
            this._chairmanText.textColor = loc1;
            this._chairmanText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._chairmanText.x = 175;
            this._chairmanText.y = 65;
            addChild(this._chairmanText);
            this._purposeText = new GTextFiled();
            this._purposeText.text = Language.getString(57020);
            this._purposeText.textColor = loc1;
            this._purposeText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._purposeText.x = 225;
            this._purposeText.y = 100;
            addChild(this._purposeText);
            this._purposeInput = new GTextInput();
            this._purposeInput.editable = false;
            this._purposeInput.styleName = "GTextInput";
            this._purposeInput.textField.wordWrap = true;
            this._purposeInput.width = 160;
            this._purposeInput.height = 70;
            this._purposeInput.x = 175;
            this._purposeInput.y = 120;
            addChild(this._purposeInput);
            return;
        }

        public updateGuildInfo(arg1: SGuildInfo): void
        {
            var loc4=null;
            var loc1=[];
            var loc2=GuildConfig.instance.getMaxNumByLevel(arg1.level) + GuildUtil.getRoomNumByLevel(arg1.house);
            loc1.push(arg1.guildName);
            loc1.push(arg1.level.toString());
            loc1.push(arg1.playerNum.toString() + "/" + loc2.toString());
            loc1.push(arg1.money.toString());
            var loc3=0;
            while (loc3 < this._fieldArray.length) 
            {
                (loc4 = this._fieldArray[loc3] as GTextFiled).htmlText = HTMLUtil.addColor(this._nameArray[loc3], "#ffff99") + HTMLUtil.addColor(loc1[loc3], "#B1F0FF");
                ++loc3;
            }
            this._campText.htmlText = HTMLUtil.addColor(Language.getString(57018), "#ffff99") + HTMLUtil.addColor(GameDefConfig.instance.getECamp(arg1.camp), "#B1F0FF");
            this._chairmanText.htmlText = HTMLUtil.addColor(Language.getString(57019), "#ffff99") + HTMLUtil.addColor(arg1.leader.name, "#B1F0FF");
            this._purposeInput.htmlText = HTMLUtil.addColor(arg1.purpose, "#B1F0FF");
            return;
        }

        public clear(): void
        {
            var loc2=null;
            var loc1=0;
            while (loc1 < this._fieldArray.length) 
            {
                loc2 = this._fieldArray[loc1] as GTextFiled;
                loc2.htmlText = HTMLUtil.addColor(this._nameArray[loc1], "#ffff99");
                ++loc1;
            }
            this._campText.htmlText = HTMLUtil.addColor(Language.getString(57018), "#ffff99");
            this._chairmanText.htmlText = HTMLUtil.addColor(Language.getString(57019), "#ffff99");
            this._purposeInput.htmlText = "";
            return;
        }

        /* internal */ /* var */_windowCenterB: ScaleBitmap;

        /* internal */ /* var */_titleLabel: GLabel;

        /* internal */ /* var */_campText: GTextFiled;

        /* internal */ /* var */_chairmanText: GTextFiled;

        /* internal */ /* var */_purposeText: GTextFiled;

        /* internal */ /* var */_purposeInput: GTextInput;

        /* internal */ /* var */_nameArray: Array<any>;

        /* internal */ /* var */_fieldArray: Array<any>;
    }
